<?php
/**
 * 制作:  叶风
 * Qq:    355007778
 * Email: ye.fn@163.com 
 * 
 */
class lang
{
	protected static $_la = array();
	
	static $dir = '';
	static function load($filename)
	{
		$file = self::$dir . $filename . '.php';
		if(is_file($file))
		 {
		 	$a = include $file;
			self::$_la = array_merge(self::$_la, $a);
			return true;
		 }
		YF_f::error( lang::g('language not exist:'). $filename);
	}
    static function _g($str)
	{
		echo  self::g($str);
	}
    //单字翻译
	static function g($str)
	{
		$l = self::$_la;
		return isset($l[$str]) ? $l[$str] :$str;
	}
	//翻译数组
	static function Ag($arr)
    {
        foreach ($arr as $k=>$v)
            $arr[$k] = self::g($v);
        return $arr;
    }
    
    /**
     * 带前标，
     * val 作为 key
     * 
     * @param type $arr
     * @param type $str
     * @return type
     */
    static function Ag_p($arr, $str='')
    {
        $A = array();
        foreach ($arr as $v)
            $A[$v] = lang::g($str . $v);
        return $A;
    }
}
?>